package com.teradata.olingo.processor.core.filter;

import org.apache.olingo.server.api.ODataApplicationException;
import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;

import javax.persistence.criteria.Expression;

class GenericBooleanOperatorImp implements GenericBooleanOperator {

  private final GenericOperationConverter converter;
  private final BinaryOperatorKind operator;
  private final GenericExpression left;
  private final GenericExpression right;

  public GenericBooleanOperatorImp(final GenericOperationConverter converter, final BinaryOperatorKind operator,
                                   final GenericExpression left, final GenericExpression right) {
    super();
    this.converter = converter;
    this.operator = operator;
    this.left = left;
    this.right = right;
  }

  /*
   * (non-Javadoc)
   * 
   * @see GenericBooleanOperator#get()
   */
  @Override
  public Expression<Boolean> get() throws ODataApplicationException {
    return converter.convert(this);
  }

  /*
   * (non-Javadoc)
   * 
   * @see GenericBooleanOperator#getOperator()
   */
  @SuppressWarnings("unchecked")
  @Override
  public BinaryOperatorKind getOperator() {
    return operator;
  }

  /*
   * (non-Javadoc)
   * 
   * @see GenericBooleanOperator#getLeft()
   */
  @Override
  public Expression<Boolean> getLeft() throws ODataApplicationException {
    return left.get();
  }

  /*
   * (non-Javadoc)
   * 
   * @see GenericBooleanOperator#getRight()
   */
  @Override
  public Expression<Boolean> getRight() throws ODataApplicationException {
    return right.get();
  }

}